/**
 *
 * @param {*} filename
 * @param {*} onLoadShader
 */
export function loadShaderFromFile(filename) {
  return new Promise((resolve, reject) => {
    var request = new XMLHttpRequest();
    request.onreadystatechange = function () {
      if (request.readyState === 4 && request.status === 200) {
        resolve(request.responseText);
      }
    };
    request.open('GET', filename, true);
    request.send();
  });
}

export function loadImgFromUrl(src) {
  return new Promise((resolve, reject) => {
    const image = new Image();
    image.src = src;
    image.crossOrigin = true;
    image.onload = function () {
      resolve(image);
    };
  });
}
